Q1. Load the "titanic" dataset using the load_dataset function of seaborn. Use Plotly express to plot a scatter plot for age and fare columns in the titanic dataset.
import seaborn as sns
import plotly.express as px
import plotly
titanic = sns.load_dataset('titanic')
fig = px.scatter(titanic, x="age", y="fare")
fig.show(renderer='notebook')
Q2. Using the tips dataset in the Plotly library, plot a box plot using Plotly express.
tips = sns.load_dataset('tips')
fig = px.box(tips, x='day', y='total_bill')
fig.show(renderer='notebook')
Q3. Using the tips dataset in the Plotly library, Plot a histogram for x = "sex" and y = "total_bill" column in the tips dataset. Also, use the "smoker" column with the pattern_shape parameter and the "day" column with the color parameter.
fig = px.histogram(tips, x="sex", y="total_bill", color="day", pattern_shape="smoker")
fig.show(renderer='notebook')
Q4. Using the iris dataset in the Plotly library, Plot a scatter matrix plot, using the "species" column for the color parameter.
iris = sns.load_dataset('iris')
fig = px.scatter_matrix(iris, dimensions=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'], color='species')
fig.show(renderer='notebook')
Q5. What is Distplot? Using Plotly express, plot a distplot.
Distplot is a function in the seaborn library that can be used to plot a histogram and a kernel density estimate (KDE) for a univariate distribution of data. The Distplot function combines the histplot and kdeplot functions into a single plot.
import plotly.express as px
import numpy as np
np.random.seed(1)
data = np.random.normal(size=1000)
fig = px.histogram(data, nbins=30, histnorm='probability density')
fig.show(renderer='notebook')
tips = sns.load_dataset("tips")
fig = px.histogram(tips, x="tip", nbins=30, opacity=0.7, marginal="box",
title="Distribution of Tips")
fig.show(renderer='notebook')